{-- 'https://github.com/Frege/frege/issues/273 Issue 273'

    Problem: functions don't type check, because the higher ranked
    function argument gets stuffed into a tuple for pattern matching by desugaring.

    Desugaring can't make it right in the first place since there may be 
    constructors whose arity we don't know yet.

    Solution: Compile the tuple pattern matches *before* type checking.
-}

module tests.comp.Issue273 where

gfoldl :: (forall d b. Maybe (d -> b) -> d -> Maybe b)
         -> (forall g. g -> Maybe g)
         -> [a]
         -> Maybe [a]


gfoldl f z []     = z []
gfoldl f z (y:ys) = (z (:) `f` y)
--                   ^^^^^^^^^^^ 
                        `f` ys
--                          ^^



bar (Just x) false = "no"
bar _        true  = "yes"

main = println (bar (Just 42) true)   -- "yes"


